package com.pheruagor.handmanager.utils {
    import flexunit.framework.Assert;
    import flexunit.framework.AssertionFailedError;

    public class TestCaseUtils {

        public static function assertException(test:Function, errorType:Class = null, message:String = "Function should have raised an exception"):void {
            var expectedError:Class = errorType;
            if (expectedError == null) {
                expectedError = Error;
            }
            try {
                test();
                Assert.fail(message);
            } catch (e:*) {
                if (e is AssertionFailedError) {
                    throw e;
                } else if (e is expectedError) {
                    Assert.assertTrue(true, "Exception " + e + " was expected");
                } else {
                    throw e;
                }
            }
        }
    }
}